package com.yitao.cms.service.expressage;

import com.skipper.base.data.querydsl.PredicateBuilder;
import com.skipper.base.service.GenericEntityService;
import com.yitao.client.dto.expressage.LogisticHeadDto;
import com.yitao.client.model.expressage.LogisticHeadModel;
import com.yitao.client.model.expressage.QLogisticHeadModel;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;

/**
 * 轨迹信息
 *
 * @Date: 2019/12/5 17:34
 * @Author: Kien
 */
@Service
public class LogisticHeadService extends GenericEntityService<LogisticHeadModel, LogisticHeadDto, QLogisticHeadModel> {

    public LogisticHeadService(EntityManager entityManager) {
        super(entityManager);
    }

    /**
     *
     * 功能描述: 根据物流公司简称和物流单号查询
     *
     * @param code 物流公司简称
     * @param number 物流单号
     * @return
     * @auther: Kien
     * @date: 2019/8/19 10:18
     */
    public LogisticHeadModel findLogisticHeadByCodeAndNumber(String code, String number){
        return repository.findOne(PredicateBuilder.conjunction()
                .and(() -> Q.logisticProvider.eq(code))
                .and(() -> Q.orderId.eq(number))
                .get());
    }
}
